package com.csi.service.impl;

import com.csi.dao.impl.RoomTypeDaoImpl;
import com.csi.dao.RoomTypeDao;
import com.csi.domain.RoomType;
import com.csi.service.RoomTypeService;

import java.sql.SQLException;
import java.util.List;

public class RoomTypeServiceImpl implements RoomTypeService {
    @Override
    public List<RoomType> select() {
        RoomTypeDao roomTypeDao=new RoomTypeDaoImpl();
        List<RoomType> list=null;
        try {
            list=roomTypeDao.select();
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return list;
    }

    @Override
    public int add(RoomType roomType) {
        RoomTypeDao roomTypeDao=new RoomTypeDaoImpl();
        int i=0;
        try {
            i=roomTypeDao.add(roomType);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return i;
    }

    @Override
    public int delete(int id) {
        RoomTypeDao roomTypeDao=new RoomTypeDaoImpl();
        int i=0;
        try {
            i=roomTypeDao.delete(id);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return i;
    }

    @Override
    public int update(RoomType roomType) {
        RoomTypeDao roomTypeDao=new RoomTypeDaoImpl();
        int i=0;
        try {
            i=roomTypeDao.update(roomType);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return i;
    }
}
